<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - gil/pixel.hpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">gil</a> - pixel.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">3</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">3</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : /*
<span class="lineNum">       2 </span>                :     Copyright 2005-2007 Adobe Systems Incorporated
<span class="lineNum">       3 </span>                :    
<span class="lineNum">       4 </span>                :     Use, modification and distribution are subject to the Boost Software License,
<span class="lineNum">       5 </span>                :     Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       6 </span>                :     http://www.boost.org/LICENSE_1_0.txt).
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span>                :     See http://opensource.adobe.com/gil for most recent version including documentation.
<span class="lineNum">       9 </span>                : */
<span class="lineNum">      10 </span>                : /*************************************************************************************************/
<span class="lineNum">      11 </span>                : 
<span class="lineNum">      12 </span>                : #ifndef GIL_PIXEL_H
<span class="lineNum">      13 </span>                : #define GIL_PIXEL_H
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      16 </span>                : /// \file               
<span class="lineNum">      17 </span>                : /// \brief pixel class and related utilities
<span class="lineNum">      18 </span>                : /// \author Lubomir Bourdev and Hailin Jin \n
<span class="lineNum">      19 </span>                : ///         Adobe Systems Incorporated
<span class="lineNum">      20 </span>                : /// \date   2005-2007 \n Last updated on September 28, 2006
<span class="lineNum">      21 </span>                : ///
<span class="lineNum">      22 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : #include &lt;functional&gt;
<span class="lineNum">      25 </span>                : #include &lt;boost/utility/enable_if.hpp&gt;
<span class="lineNum">      26 </span>                : #include &lt;boost/mpl/bool.hpp&gt;
<span class="lineNum">      27 </span>                : #include &lt;boost/mpl/front.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/type_traits.hpp&gt;
<span class="lineNum">      29 </span>                : #include &quot;gil_config.hpp&quot;
<span class="lineNum">      30 </span>                : #include &quot;color_base.hpp&quot;
<span class="lineNum">      31 </span>                : #include &quot;gil_concept.hpp&quot;
<span class="lineNum">      32 </span>                : #include &quot;channel.hpp&quot;
<span class="lineNum">      33 </span>                : #include &quot;metafunctions.hpp&quot;
<span class="lineNum">      34 </span>                : #include &quot;utilities.hpp&quot;
<span class="lineNum">      35 </span>                : #include &quot;color_base_algorithm.hpp&quot;
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : namespace boost { namespace gil {
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                : // Forward-declare gray_t
<span class="lineNum">      40 </span>                : struct gray_color_t;
<span class="lineNum">      41 </span>                : typedef mpl::vector1&lt;gray_color_t&gt; gray_t;
<span class="lineNum">      42 </span>                : template &lt;typename PixelBased&gt; struct color_space_type;
<span class="lineNum">      43 </span>                : template &lt;typename PixelBased&gt; struct channel_mapping_type;
<span class="lineNum">      44 </span>                : template &lt;typename PixelBased&gt; struct channel_type;
<span class="lineNum">      45 </span>                : template &lt;typename PixelBased&gt; struct is_planar;
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : template &lt;typename PixelBased&gt; struct color_space_type&lt;const PixelBased&gt; : public color_space_type&lt;PixelBased&gt; {};
<span class="lineNum">      48 </span>                : template &lt;typename PixelBased&gt; struct channel_mapping_type&lt;const PixelBased&gt; : public channel_mapping_type&lt;PixelBased&gt; {};
<span class="lineNum">      49 </span>                : template &lt;typename PixelBased&gt; struct channel_type&lt;const PixelBased&gt; : public channel_type&lt;PixelBased&gt; {};
<span class="lineNum">      50 </span>                : template &lt;typename PixelBased&gt; struct is_planar&lt;const PixelBased&gt; : public is_planar&lt;PixelBased&gt; {};
<span class="lineNum">      51 </span>                : 
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                : template &lt;typename T&gt; struct is_pixel : public mpl::false_{};
<span class="lineNum">      54 </span>                : template &lt;typename T&gt; struct is_pixel&lt;const T&gt; : public is_pixel&lt;T&gt; {};
<span class="lineNum">      55 </span>                : 
<span class="lineNum">      56 </span>                : /// \ingroup PixelBasedAlgorithm
<span class="lineNum">      57 </span>                : /// \brief Returns the number of channels of a pixel-based GIL construct
<span class="lineNum">      58 </span>                : template &lt;typename PixelBased&gt;
<span class="lineNum">      59 </span>                : struct num_channels : public mpl::size&lt;typename color_space_type&lt;PixelBased&gt;::type&gt; {}; 
<span class="lineNum">      60 </span>                : 
<span class="lineNum">      61 </span>                : /**
<span class="lineNum">      62 </span>                : \addtogroup PixelBasedAlgorithm
<span class="lineNum">      63 </span>                : 
<span class="lineNum">      64 </span>                : Example:
<span class="lineNum">      65 </span>                : \code
<span class="lineNum">      66 </span>                : BOOST_STATIC_ASSERT((num_channels&lt;rgb8_view_t&gt;::value==3));
<span class="lineNum">      67 </span>                : BOOST_STATIC_ASSERT((num_channels&lt;cmyk16_planar_ptr_t&gt;::value==4));
<span class="lineNum">      68 </span>                : 
<span class="lineNum">      69 </span>                : BOOST_STATIC_ASSERT((is_planar&lt;rgb16_planar_image_t&gt;::value));
<span class="lineNum">      70 </span>                : BOOST_STATIC_ASSERT((is_same&lt;color_space_type&lt;rgb8_planar_ref_t&gt;::type, rgb_t&gt;::value));
<span class="lineNum">      71 </span>                : BOOST_STATIC_ASSERT((is_same&lt;channel_mapping_type&lt;cmyk8_pixel_t&gt;::type, 
<span class="lineNum">      72 </span>                :                              channel_mapping_type&lt;rgba8_pixel_t&gt;::type&gt;::value));
<span class="lineNum">      73 </span>                : BOOST_STATIC_ASSERT((is_same&lt;channel_type&lt;bgr8_pixel_t&gt;::type, bits8&gt;::value));
<span class="lineNum">      74 </span>                : \endcode
<span class="lineNum">      75 </span>                : */
<span class="lineNum">      76 </span>                : 
<span class="lineNum">      77 </span>                : /// \defgroup ColorBaseModelPixel pixel 
<span class="lineNum">      78 </span>                : /// \ingroup ColorBaseModel
<span class="lineNum">      79 </span>                : /// \brief A homogeneous color base whose element is a channel value. Models HomogeneousColorBaseValueConcept
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span>                : /// \defgroup PixelModelPixel pixel 
<span class="lineNum">      82 </span>                : /// \ingroup PixelModel
<span class="lineNum">      83 </span>                : /// \brief A homogeneous pixel value. Models HomogeneousPixelValueConcept
<span class="lineNum">      84 </span>                : 
<span class="lineNum">      85 </span>                : /// \ingroup PixelModelPixel ColorBaseModelPixel PixelBasedModel
<span class="lineNum">      86 </span>                : /// \brief Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept, PixelValueConcept, HomogeneousPixelBasedConcept
<span class="lineNum">      87 </span>                : /// 
<span class="lineNum">      88 </span>                : /// A pixel is a set of channels defining the color at a given point in an image. Conceptually, a pixel is little more than a color base whose elements 
<span class="lineNum">      89 </span>                : /// model \p ChannelConcept. The class \p pixel defines a simple, homogeneous pixel value. It is used to store 
<span class="lineNum">      90 </span>                : /// the value of a color. The built-in C++ references to \p pixel, \p pixel&amp; and \p const \p pixel&amp; are used to represent a reference to a pixel
<span class="lineNum">      91 </span>                : /// inside an interleaved image view (a view in which all channels are together in memory). Similarly, built-in pointer types \p pixel* and \p const \p pixel*
<span class="lineNum">      92 </span>                : /// are used as the standard iterator over a row of interleaved homogeneous pixels. 
<span class="lineNum">      93 </span>                : ///
<span class="lineNum">      94 </span>                : /// Since \p pixel inherits the properties of color base, assigning, equality comparison and copy-construcion are allowed between compatible pixels.
<span class="lineNum">      95 </span>                : /// This means that an 8-bit RGB pixel may be assigned to an 8-bit BGR pixel, or to an 8-bit planar reference. The channels are properly paired semantically.
<span class="lineNum">      96 </span>                : ///
<span class="lineNum">      97 </span>                : /// The single-channel (grayscale) instantiation of the class pixel, (i.e. \p pixel&lt;T,gray_layout_t&gt;) is also convertible to/from a channel value.
<span class="lineNum">      98 </span>                : /// This allows grayscale pixels to be used in simpler expressions like *gray_pix1 = *gray_pix2  instead of more complicated at_c&lt;0&gt;(gray_pix1) = at_c&lt;0&gt;(gray_pix2)
<span class="lineNum">      99 </span>                : /// or get_color&lt;gray_color_t&gt;(gray_pix1) = get_color&lt;gray_color_t&gt;(gray_pix2)
<span class="lineNum">     100 </span>                : 
<span class="lineNum">     101 </span>                : template &lt;typename ChannelValue, typename Layout&gt; // = mpl::range_c&lt;int,0,ColorSpace::size&gt; &gt;
<span class="lineNum">     102 </span>                : struct pixel : public detail::homogeneous_color_base&lt;ChannelValue,Layout,mpl::size&lt;typename Layout::color_space_t&gt;::value&gt; {
<span class="lineNum">     103 </span>                : private:
<span class="lineNum">     104 </span>                :     typedef ChannelValue channel_t;
<span class="lineNum">     105 </span>                :     typedef detail::homogeneous_color_base&lt;ChannelValue,Layout,mpl::size&lt;typename Layout::color_space_t&gt;::value&gt; parent_t;
<span class="lineNum">     106 </span>                : public:
<span class="lineNum">     107 </span>                :     typedef pixel                               value_type;
<span class="lineNum">     108 </span>                :     typedef value_type&amp;                         reference;
<span class="lineNum">     109 </span>                :     typedef const value_type&amp;                   const_reference;
<span class="lineNum">     110 </span>                :     BOOST_STATIC_CONSTANT(bool,                 is_mutable = channel_traits&lt;channel_t&gt;::is_mutable);
<span class="lineNum">     111 </span>                : 
<span class="lineNum">     112 </span><span class="lineCov">              6 :     pixel(){}</span>
<span class="lineNum">     113 </span>                :     explicit pixel(channel_t v) : parent_t(v) {}  // sets all channels to v
<span class="lineNum">     114 </span>                :     pixel(channel_t v0, channel_t v1)                                                         : parent_t(v0,v1) {}
<span class="lineNum">     115 </span>                :     pixel(channel_t v0, channel_t v1, channel_t v2)                                           : parent_t(v0,v1,v2) {}
<span class="lineNum">     116 </span>                :     pixel(channel_t v0, channel_t v1, channel_t v2, channel_t v3)                             : parent_t(v0,v1,v2,v3) {}
<span class="lineNum">     117 </span>                :     pixel(channel_t v0, channel_t v1, channel_t v2, channel_t v3, channel_t v4)               : parent_t(v0,v1,v2,v3,v4) {}
<span class="lineNum">     118 </span>                :     pixel(channel_t v0, channel_t v1, channel_t v2, channel_t v3, channel_t v4, channel_t v5) : parent_t(v0,v1,v2,v3,v4,v5) {}
<span class="lineNum">     119 </span>                : 
<span class="lineNum">     120 </span><span class="lineCov">           1662 :     pixel(const pixel&amp; p) : parent_t(p) {}</span>
<span class="lineNum">     121 </span><span class="lineCov">         142932 :     pixel&amp;                       operator=(const pixel&amp; p)       { static_copy(p,*this); return *this; }</span>
<span class="lineNum">     122 </span>                : 
<span class="lineNum">     123 </span>                :     // Construct from another compatible pixel type
<span class="lineNum">     124 </span>                :     template &lt;typename Pixel&gt;    pixel(const Pixel&amp; p, typename enable_if_c&lt;is_pixel&lt;Pixel&gt;::value&gt;::type* dummy = 0) : parent_t(p) { 
<span class="lineNum">     125 </span>                :         check_compatible&lt;Pixel&gt;();
<span class="lineNum">     126 </span>                :     }   
<span class="lineNum">     127 </span>                : 
<span class="lineNum">     128 </span>                :     template &lt;typename P&gt; pixel&amp; operator=(const P&amp; p)           { assign(p, mpl::bool_&lt;is_pixel&lt;P&gt;::value&gt;()); return *this; } 
<span class="lineNum">     129 </span>                :     template &lt;typename P&gt; bool   operator==(const P&amp; p)    const { return equal(p, mpl::bool_&lt;is_pixel&lt;P&gt;::value&gt;()); } 
<span class="lineNum">     130 </span>                : 
<span class="lineNum">     131 </span>                :     template &lt;typename P&gt; bool   operator!=(const P&amp; p)    const { return !(*this==p); }
<span class="lineNum">     132 </span>                : 
<span class="lineNum">     133 </span>                :     // homogeneous pixels have operator[]
<span class="lineNum">     134 </span>                :     typename channel_traits&lt;channel_t&gt;::reference       operator[](std::size_t i)       { return dynamic_at_c(*this,i); }
<span class="lineNum">     135 </span>                :     typename channel_traits&lt;channel_t&gt;::const_reference operator[](std::size_t i) const { return dynamic_at_c(*this,i); }
<span class="lineNum">     136 </span>                : private:
<span class="lineNum">     137 </span>                :     template &lt;typename Pixel&gt; void assign(const Pixel&amp; p, mpl::true_)       { check_compatible&lt;Pixel&gt;(); static_copy(p,*this); } 
<span class="lineNum">     138 </span>                :     template &lt;typename Pixel&gt; bool  equal(const Pixel&amp; p, mpl::true_) const { check_compatible&lt;Pixel&gt;(); return static_equal(*this,p); } 
<span class="lineNum">     139 </span>                : 
<span class="lineNum">     140 </span>                :     template &lt;typename Pixel&gt; void check_compatible() const { gil_function_requires&lt;PixelsCompatibleConcept&lt;Pixel,pixel&gt; &gt;(); }
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                : // Support for assignment/equality comparison of a channel with a grayscale pixel
<span class="lineNum">     143 </span>                : 
<span class="lineNum">     144 </span>                : private:
<span class="lineNum">     145 </span>                :     static void check_gray() {  BOOST_STATIC_ASSERT((is_same&lt;typename Layout::color_space_t, gray_t&gt;::value)); }
<span class="lineNum">     146 </span>                :     template &lt;typename Channel&gt; void assign(const Channel&amp; chan, mpl::false_)       { check_gray(); at_c&lt;0&gt;(*this)=chan; }
<span class="lineNum">     147 </span>                :     template &lt;typename Channel&gt; bool equal (const Channel&amp; chan, mpl::false_) const { check_gray(); return at_c&lt;0&gt;(*this)==chan; }
<span class="lineNum">     148 </span>                : public:
<span class="lineNum">     149 </span>                :     pixel&amp;  operator= (channel_t chan)       { check_gray(); at_c&lt;0&gt;(*this)=chan; return *this; }
<span class="lineNum">     150 </span>                :     bool    operator==(channel_t chan) const { check_gray(); return at_c&lt;0&gt;(*this)==chan; }
<span class="lineNum">     151 </span>                : };
<span class="lineNum">     152 </span>                : 
<span class="lineNum">     153 </span>                : /////////////////////////////
<span class="lineNum">     154 </span>                : //  ColorBasedConcept
<span class="lineNum">     155 </span>                : /////////////////////////////
<span class="lineNum">     156 </span>                : 
<span class="lineNum">     157 </span>                : template &lt;typename ChannelValue, typename Layout, int K&gt;  
<span class="lineNum">     158 </span>                : struct kth_element_type&lt;pixel&lt;ChannelValue,Layout&gt;, K&gt; {
<span class="lineNum">     159 </span>                :     typedef ChannelValue type;
<span class="lineNum">     160 </span>                : };
<span class="lineNum">     161 </span>                : 
<span class="lineNum">     162 </span>                : template &lt;typename ChannelValue, typename Layout, int K&gt;  
<span class="lineNum">     163 </span>                : struct kth_element_reference_type&lt;pixel&lt;ChannelValue,Layout&gt;, K&gt; {
<span class="lineNum">     164 </span>                :     typedef typename channel_traits&lt;ChannelValue&gt;::reference type;
<span class="lineNum">     165 </span>                : };
<span class="lineNum">     166 </span>                : 
<span class="lineNum">     167 </span>                : template &lt;typename ChannelValue, typename Layout, int K&gt;  
<span class="lineNum">     168 </span>                : struct kth_element_reference_type&lt;const pixel&lt;ChannelValue,Layout&gt;, K&gt; {
<span class="lineNum">     169 </span>                :     typedef typename channel_traits&lt;ChannelValue&gt;::const_reference type;
<span class="lineNum">     170 </span>                : };
<span class="lineNum">     171 </span>                : 
<span class="lineNum">     172 </span>                : template &lt;typename ChannelValue, typename Layout, int K&gt;  
<span class="lineNum">     173 </span>                : struct kth_element_const_reference_type&lt;pixel&lt;ChannelValue,Layout&gt;, K&gt; {
<span class="lineNum">     174 </span>                :     typedef typename channel_traits&lt;ChannelValue&gt;::const_reference type;
<span class="lineNum">     175 </span>                : };
<span class="lineNum">     176 </span>                : 
<span class="lineNum">     177 </span>                : /////////////////////////////
<span class="lineNum">     178 </span>                : //  PixelConcept
<span class="lineNum">     179 </span>                : /////////////////////////////
<span class="lineNum">     180 </span>                : 
<span class="lineNum">     181 </span>                : template &lt;typename ChannelValue, typename Layout&gt; 
<span class="lineNum">     182 </span>                : struct is_pixel&lt;pixel&lt;ChannelValue,Layout&gt; &gt; : public mpl::true_{};
<span class="lineNum">     183 </span>                : 
<span class="lineNum">     184 </span>                : /////////////////////////////
<span class="lineNum">     185 </span>                : //  HomogeneousPixelBasedConcept
<span class="lineNum">     186 </span>                : /////////////////////////////
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                : template &lt;typename ChannelValue, typename Layout&gt;
<span class="lineNum">     189 </span>                : struct color_space_type&lt;pixel&lt;ChannelValue,Layout&gt; &gt; {
<span class="lineNum">     190 </span>                :     typedef typename Layout::color_space_t type;
<span class="lineNum">     191 </span>                : }; 
<span class="lineNum">     192 </span>                : 
<span class="lineNum">     193 </span>                : template &lt;typename ChannelValue, typename Layout&gt;
<span class="lineNum">     194 </span>                : struct channel_mapping_type&lt;pixel&lt;ChannelValue,Layout&gt; &gt; {
<span class="lineNum">     195 </span>                :     typedef typename Layout::channel_mapping_t type;
<span class="lineNum">     196 </span>                : }; 
<span class="lineNum">     197 </span>                : 
<span class="lineNum">     198 </span>                : template &lt;typename ChannelValue, typename Layout&gt;
<span class="lineNum">     199 </span>                : struct is_planar&lt;pixel&lt;ChannelValue,Layout&gt; &gt; : public mpl::false_ {};
<span class="lineNum">     200 </span>                : 
<span class="lineNum">     201 </span>                : template &lt;typename ChannelValue, typename Layout&gt;
<span class="lineNum">     202 </span>                : struct channel_type&lt;pixel&lt;ChannelValue,Layout&gt; &gt; {
<span class="lineNum">     203 </span>                :     typedef ChannelValue type;
<span class="lineNum">     204 </span>                : }; 
<span class="lineNum">     205 </span>                : 
<span class="lineNum">     206 </span>                : } }  // namespace boost::gil
<span class="lineNum">     207 </span>                : 
<span class="lineNum">     208 </span>                : namespace boost {
<span class="lineNum">     209 </span>                :     template &lt;typename ChannelValue, typename Layout&gt; 
<span class="lineNum">     210 </span>                :     struct has_trivial_constructor&lt;gil::pixel&lt;ChannelValue,Layout&gt; &gt; : public has_trivial_constructor&lt;ChannelValue&gt; {};
<span class="lineNum">     211 </span>                : }
<span class="lineNum">     212 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
